$(function() {
	var $order = $('#Orders');
	var $name = $('#name');
	var $drink = $('#drink');
	$.ajax({
		url : "OrderController",
		type : "GET",
		datatype : 'json',
		success : function(data) {
			//console.log('success', data);
			var data1 = JSON.parse(data);
			for (var i = 0; i < data1.listCompanyType.length; i++) {
				$order.append("<li>" + "name:" + data1.listCompanyType[i].name
						+ "\t drink:" + data1.listCompanyType[i].drink
						+ "</li>");
			}
		},
		error : function(data) {
			alert("Don't reload!");
		}
	});

	$('#add-Order').on(
			'click',
			function() {
				var order = {
					name : $name.val(),
					drink : $drink.val()
				};
				$.ajax({
					type : "POST",
					url : "OrderController",
					data : order,
					success : function(data) {
						//console.log('success', data);
						var data1 = JSON.parse(data);
						$order.append("<li>" + "name:" + data1.name
								+ "\t drink:" + data1.drink + "</li>");
					},
					error : function() {
						alert("add order fail");
					}
				});
			});

});
